﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Data;
using System.Globalization;

namespace BDSim
{
    public class ForceWndViewModel : INotifyPropertyChanged
    {
        private OrbitPredictParamClass _COrbitPredictParam = new OrbitPredictParamClass();

        private IntegrationParamClass _IntegrationParam = new IntegrationParamClass();
        /// <summary>
        /// 轨道力模型参数，界面配置
        /// </summary>      

        public OrbitPredictParamClass COrbitPredictParam
        {
            get { return _COrbitPredictParam; }
            set { _COrbitPredictParam = value; NotifyPropertyChanged("COrbitPredictParam"); }
        }

        /// <summary>
        /// 积分器参数，界面设置
        /// </summary>
        public IntegrationParamClass IntegrationParam
        {
            get { return _IntegrationParam; }
            set { _IntegrationParam = value; NotifyPropertyChanged("IntegrationParam"); }
        } 


        /// <summary>
        /// 界面显示积分器类型选择
        /// </summary>
        List<EIntegratorType> _IntegratorList = new List<EIntegratorType>() { EIntegratorType.KSG, EIntegratorType.RKF7 };        
        public List<EIntegratorType> IntegratorList
        {
            get { return _IntegratorList; }
            set { _IntegratorList = value; NotifyPropertyChanged("IntegratorList"); }
        }

        List<EPropagateType> _PropagateList = new List<EPropagateType>() { EPropagateType.HPOP, EPropagateType.TwoBody };        
        public List<EPropagateType> PropagateList
        {
            get { return _PropagateList; }
            set { _PropagateList = value; NotifyPropertyChanged("PropagateList"); }
        }

        /// <summary>
        /// 引力场模型类型选择
        /// </summary>
        List<EEarthPotentialModel> _EarthPotentialModelList = new List<EEarthPotentialModel>() { EEarthPotentialModel.JGM3 };        
        public List<EEarthPotentialModel> EarthPotentialModelList
        {
            get { return _EarthPotentialModelList; }
            set { _EarthPotentialModelList = value; NotifyPropertyChanged("EarthPotentialModelList"); }
        }


        List<ESrpModel> _SrpModelList = new List<ESrpModel>() { ESrpModel.球模型, ESrpModel.六参数模型, ESrpModel.九参数Bernese模型};
        public List<ESrpModel> SrpModelList
        {
            get { return _SrpModelList; }
            set { _SrpModelList = value; NotifyPropertyChanged("SrpModelList"); }
        }

        List<EShadeModel> _ShadeModelList = new List<EShadeModel>() { EShadeModel.不考虑, EShadeModel.柱形模型, EShadeModel.锥形模型 };
        public List<EShadeModel> ShadeModelList
        {
            get { return _ShadeModelList; }
            set { _ShadeModelList = value; }
        }

       #region //属性通知
       public event PropertyChangedEventHandler PropertyChanged;

       public void NotifyPropertyChanged(string propertyName)
       {
           if (PropertyChanged != null)
           {
               PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
           }
       }
       #endregion

    }

    #region 数据类型转换接口的实现类

    public class PropagateTypeToBool : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool IsEnabled = true;            
            if ((EPropagateType)value == EPropagateType.TwoBody)
            {
                IsEnabled = false;
            }
            return IsEnabled;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class SrpModelConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int SrpModel = 0;
            ESrpModel type = (ESrpModel)value;
            switch (type)
            {
                case ESrpModel.球模型:
                    SrpModel = 0;
                    break;
                case ESrpModel.六参数模型:
                    SrpModel = 1;
                    break;
                case ESrpModel.九参数Bernese模型:
                    SrpModel = 2;
                    break;
                default:
                    break;
            }
            return SrpModel;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int SrpModel = 0;
            ESrpModel type = (ESrpModel)value;
            switch (type)
            {
                case ESrpModel.球模型:
                    SrpModel = 0;
                    break;
                case ESrpModel.六参数模型:
                    SrpModel = 1;
                    break;
                case ESrpModel.九参数Bernese模型:
                    SrpModel = 2;
                    break;
                default:
                    break;
            }
            return SrpModel;
        }
    }

    public class ShadModelConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int ShadModel = 0;
            return ShadModel;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int ShadModel = 0;
            EShadeModel type = (EShadeModel)value;
            switch (type)
            {
                case EShadeModel.不考虑:
                    ShadModel = 0;
                    break;
                case EShadeModel.柱形模型:
                    ShadModel = 1;
                    break;
                case EShadeModel.锥形模型:
                    ShadModel = 2;
                    break;
                default:
                    break;
            }
            return ShadModel;
        }
    }
    #endregion
}
